﻿@using EFEntity
@using Model
@model Esalary_grant_details

@{
    Layout = null;
}
<script src="~/Scripts/vue.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/javascript/echarts.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<link href="~/lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
@***薪酬发放登记 ***@
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="../../css/table.css" type="text/css" />
    <title>无标题文档</title>
    <style type="text/css">
        <!--
        .style3 {
            color: #0000CC
        }

        td {
            text-align: center
        }
        -->
    </style>


</head>

<body>
    <div id="app">
        <form method="post" action="/salaryGrant/register_Add">
            <table width="100%">
                <tr>
                    <td colspan="2" style="text-align: left">
                        <font color="black">
                            您正在做的业务是：人力资源--薪酬标准管理--薪酬发放登记
                        </font>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align: right;">
                        <input type="submit" value="提交" class="BUTTON_STYLE1">
                        <input type="button" value="返回" onclick="javascript:window.history.back();" class="BUTTON_STYLE1">
                    </td>
                </tr>
                @foreach (Esalary_grant aa in ViewBag.es)
                {
                    <tr>
                        <td colspan="2" style="text-align: left">
                            薪酬单编号：@aa.salary_standard_id
                            <input type="text" asp-for="salary_grant_id" id="salary_grant_id" readonly="readonly">
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: left">
                            本机构总人数:@aa.human_amount
                            <input type="hidden" name="salaryGrant.humanAmount" value="5">
                            ，基本薪酬总数:@aa.salary_standard_sum
                            ，实发总额:<span id="salarySum_sum">@aa.salary_paid_sum</span>
                            <input type="hidden" id="salaryPaidSum" name="salaryGrant.salaryPaidSum" value="00.00" />

                        </td>
                        <td style="text-align: right;">
                            登记人:<input type="text" name="salaryGrant.register" value="冉冉" size="8" readonly="readonly">
                            登记时间：<span id="Tdate"></span>
                            <input type="hidden" name="salaryGrant.registTime" id="Tdate2">
                        </td>
                    </tr>
                }
            </table>


            <table width="100%" border="1" cellpadding=0 cellspacing=1
                   bordercolorlight=#848284 bordercolordark=#eeeeee
                   class="table table-bordered">
                <tr class="alert-info">
                    <td class="TD_STYLE1">
                        <span>序号</span>
                    </td>
                    <td class="TD_STYLE1">
                        <span>档案编号</span>
                    </td>
                    <td class="TD_STYLE1">
                        <span>姓名</span>
                    </td>

                    <td class="TD_STYLE1">
                        薪酬基本明细
                    </td>

                    <td class="TD_STYLE1" width="7%">
                        奖励金额
                    </td>
                    <td class="TD_STYLE1" width="7%">
                        销售绩效总额
                    </td>
                    <td class="TD_STYLE1" width="7%">
                        应扣金额
                    </td>
                    <td class="TD_STYLE1" width="7%">
                        实发金额
                    </td>
                </tr>
                <input type="hidden" id="salaryStandardSum1" name="grantDetails[0].salaryStandardSum" value="@ViewData["num"]" />
                @foreach (Esalary_grant item in ViewBag.es)
                {
                    <tr class="TD_STYLE2">
                        <td>
                            @Html.DisplayFor(modelItem => item.salary_grant_id)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.salary_standard_id)
                        </td>
                        @foreach (Esalary_standard ss in ViewBag.ss)
                        {
                            <td>
                                @ss.standard_name
                                <input type="hidden" asp-for="human_name" value="@ss.standard_name" />
                            </td>
                        }
                        <td>
                            <input type="button" data-toggle="modal" data-target="#XinChou" value="详细内容" />
                        </td>

                        <td>
                            <input type="text" asp-for="bouns_sum" id="bounsSum1" onkeyup="onKeyPress('1')" class="INPUT_STYLE2" size="10" />
                        </td>
                        <td>
                            <input type="text" asp-for="sale_sum" id="saleSum1" onkeyup="onKeyPress('1')" class="INPUT_STYLE2" size="10" />
                        </td>
                        <td>
                            <input type="text" asp-for="deduct_sum" id="deductSum1" onkeyup="onKeyPress('1')" class="INPUT_STYLE2" size="10" />
                        </td>
                        <td>
                            <input type="text" asp-for="salary_paid_sum" readonly="readonly" id="salaryPaidSum1" value="@ViewData["num"]" class="INPUT_STYLE2" size="10" />
                        </td>
                    </tr>
                }
            </table>
        </form>

        @* 薪酬信息单模态框开始 *@
        <div class="modal fade" id="XinChou" tabindex="-1" role="dialog"
             aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel">
                            薪酬标准单详细信息
                        </h4>
                    </div>
                    <form role="form" id="FormUpdate">
                        <div class="modal-body">
                            @foreach (salary_standard_details ss in ViewBag.ssd)
                            {
                                @ss.item_name <label for="name">$$ : </label>@ss.salary<br />

                            }
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default"
                                    data-dismiss="modal">
                                关闭
                            </button>

                        </div>
                    </form>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>
        @* 薪酬信息单模态框结束 *@
    </div>
    <SCRIPT type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                num: 0
            },
            methods: {
                //ID随机数
                standarid: function () {
                    var randoms = [];
                    while (true) {
                        var isExists = false;
                        //获取一个10-100范围的数
                        var random = parseInt(10 + (90 - 10) * (Math.random()));
                        //判断当前随机数是否已经存在
                        for (var i = 0; i < randoms.length; i++) {
                            if (random === randoms[i]) {
                                isExists = true;
                                break;
                            }
                        }
                        // 如果zhi不存在，则添加进去
                        if (!isExists)
                            randoms.push(random);
                        // 如果有10位随机数了，就跳出
                        if (randoms.length === 2)
                            break;
                    }
                    //把数组中的','用空代替
                    randoms = randoms.join('');
                    var data = new Date();
                    var year = data.getFullYear();
                    var month = data.getMonth() + 1;
                    var day = data.getDate();
                    var Time = data.getHours();
                    $("#salary_grant_id").val("HS" + year + month + day + Time + randoms);
                }
            },
            mounted: function () {
                this.standarid();
            }
        });

        function onKeyPress(i) {
            var size = 5;
            var bounsSum = document.getElementById("bounsSum" + i);
            var saleSum = document.getElementById("saleSum" + i);
            var deductSum = document.getElementById("deductSum" + i);
            var salaryPaidSum = document.getElementById("salaryPaidSum" + i);
            if (isNaN(bounsSum.value) || bounsSum.value < 0) {
                alert("金额填写错误!");
                bounsSum.value = "0.00";
                return;
            }
            if (isNaN(saleSum.value) || saleSum.value < 0) {
                alert("金额填写错误!");
                saleSum.value = "0.00";
                return;
            }
            if (isNaN(deductSum.value) || deductSum.value < 0) {
                alert("金额填写错误!");
                deductSum.value = "0.00";
                return;
            }
            salaryPaidSum.value = Number(bounsSum.value) + Number(saleSum.value) - Number(deductSum.value) + Number(document.getElementById("salaryStandardSum" + i).value);

            var sum = 0;
            for (var j = 1; j <= size; j++) {
                sum = Number(sum) + Number(document.getElementById("salaryPaidSum" + j).value);
            }
            document.getElementById("salarySum_sum").innerHTML = sum;
            document.getElementById("salaryPaidSum").value = sum;

        }

        function time() {
            var tdate = document.getElementById("Tdate");
            var d = new Date();
            var y = d.getFullYear();
            var moth = d.getMonth() + 1;
            var date = d.getDate();
            var h = d.getHours();
            var m = d.getMinutes();
            var s = d.getSeconds();
            var hh = 20 - 1 - h;
            var mm = 60 - 1 - m;
            var ss = 60 - s;
            if (hh > 0) {
                mm = mm + 60 * hh;
            }
            if (moth < 10) {
                moth = "0" + moth;
            }
            if (date < 10) {
                date = "0" + date;
            }
            if (h < 10) {
                h = "0" + h;
            }
            if (m < 10) {
                m = "0" + m;
            }
            if (s < 10) {
                s = "0" + s;
            }
            if (mm < 10) {
                mm = "0" + mm;
            }
            if (ss < 10) {
                ss = "0" + ss;
            }

            tdate.innerHTML = y + "-" + moth + "-" + date + " " + h + ":" + m + ":" + s;
            document.getElementById("Tdate2").value = tdate.innerHTML;
        }
        window.onload = time;
        var out = window.setInterval(time, 1000);


    </SCRIPT>
</body>
</html>

